package com.rexolar.openapi.listener;

import com.rexolar.openapi.job.AppSyncJob;
import com.rexolar.openapi.job.GwDeviceSyncJob;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.context.event.ApplicationReadyEvent;
import org.springframework.context.event.EventListener;
import org.springframework.stereotype.Component;

@Component
public class AppReadyEventListener {
    @Autowired
    AppSyncJob appSyncJob;

    @Autowired
    GwDeviceSyncJob gwDeviceSyncJob;

    @EventListener(ApplicationReadyEvent.class)
    public void onApplicationEvent(ApplicationReadyEvent event) {
        // 完全启动后执行的代码
        System.out.println("应用完全启动");
        appSyncJob.syncPartnerInfo();
        gwDeviceSyncJob.syncGwDeviceRelation();
        gwDeviceSyncJob.syncGwStatus();
    }
}
